package com.woniuxy.service.impl;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.woniuxy.entity.RbacRole;
import com.woniuxy.mapper.RbacRoleMapper;
import com.woniuxy.service.RbacRoleService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * <p>
 * 角色表 服务实现类
 * </p>
 *
 * @author linKe
 * @since 2021-11-25
 */
@Service
public class RbacRoleServiceImpl extends ServiceImpl<RbacRoleMapper, RbacRole> implements RbacRoleService {
    /**
     * 注入mapper持久层对象
     */
    @Resource
    private RbacRoleMapper rbacRoleMapper;


    @Override
    public Page<RbacRole> findAllPage(int currentPage, int size) {
        Page<RbacRole> page = new Page<>(currentPage,size);
        return rbacRoleMapper.selectPage(page, null);
    }

    @Override
    public RbacRole findOneById(int id) {
        return rbacRoleMapper.selectById(id);
    }

    @Override
    public int addRole(RbacRole rbacRole) {
        return rbacRoleMapper.insert(rbacRole);
    }

    @Override
    public int updateRole(RbacRole rbacRole) {
        return rbacRoleMapper.updateById(rbacRole);
    }

    @Override
    public int deleteRole(int id) {
        return rbacRoleMapper.deleteById(id);
    }

    @Override
    public List<RbacRole> findAllRole() {
        return rbacRoleMapper.selectList(null);
    }
}
